package com.bw.a525zy.New

import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.databinding.DataBindingUtil
import androidx.paging.PagingDataAdapter
import androidx.recyclerview.widget.DiffUtil.ItemCallback
import androidx.recyclerview.widget.RecyclerView
import com.bw.a525zy.R
import com.bw.a525zy.databinding.NeBinding
import com.bw.base.entity.NewEntityItem

class NewApter:PagingDataAdapter<NewEntityItem,NewApter.NewHolder>(new) {
    companion object{
        val new =object :ItemCallback<NewEntityItem>(){
            override fun areItemsTheSame(oldItem: NewEntityItem, newItem: NewEntityItem): Boolean {
                return oldItem==newItem
            }

            override fun areContentsTheSame(
                oldItem: NewEntityItem,
                newItem: NewEntityItem,
            ): Boolean {
              return oldItem.id==newItem.id
            }

        }
    }
    class NewHolder (view: View):RecyclerView.ViewHolder(view){
        val binding=DataBindingUtil.bind<NeBinding>(view)
    }
    override fun onBindViewHolder(holder: NewApter.NewHolder, position: Int) {
        holder.binding?.new1=getItem(position)
    }

    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): NewApter.NewHolder {
        val inflate = LayoutInflater.from(parent.context).inflate(R.layout.ne, parent, false)
        return NewHolder(inflate)
    }
}